-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Fix Spliterator characteristics in ConcurrentReferenceHashMap
#35817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
kilink
wants to merge
1
commit into
spring-projects:main
from
kilink:concurrent-reference-hash-map-fix-spliterators
Closed
Fix Spliterator characteristics in ConcurrentReferenceHashMap
#35817
kilink
wants to merge
1
commit into
spring-projects:main
from
kilink:concurrent-reference-hash-map-fix-spliterators
+338
−16
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Spliterators returned by values, entrySet, and keySet incorrectly reported the SIZED characteristic, instead of CONCURRENT. This could lead to bugs when the map is concurrently modified during a stream operation. For keySet and values, the incorrect characteristics are inherited from AbstractMap, so to rectify that the respective methods are overridden and custom collections are provided that report the correct Spliterator characteristics. Signed-off-by: Patrick Strawderman <pstrawderman@netflix.com>
aefaa72 to
e4b7baf
Compare
kilink
commented
Nov 13, 2025
spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java
Show resolved
Hide resolved
Contributor
|
Good point, let's fix this for 7.0.1. This is also worth backporting to 6.2.14. |
Spliterator characteristics in ConcurrentReferenceHashMap
sbrannen
added a commit
that referenced
this pull request
Nov 17, 2025
sbrannen
pushed a commit
that referenced
this pull request
Nov 17, 2025
The Spliterators returned by values, entrySet, and keySet incorrectly reported the SIZED characteristic, instead of CONCURRENT. This could lead to bugs when the map is concurrently modified during a stream operation. For keySet and values, the incorrect characteristics are inherited from AbstractMap, so to rectify that the respective methods are overridden, and custom collections are provided that report the correct Spliterator characteristics. Closes gh-35817 Signed-off-by: Patrick Strawderman <pstrawderman@netflix.com> (cherry picked from commit ed75906)
Member
|
This has been merged into Thanks 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Spliterators returned by values, entrySet, and keySet incorrectly reported the SIZED characteristic, instead of CONCURRENT. This could lead to bugs when the map is concurrently modified during a stream operation.
For keySet and values, the incorrect characteristics are inherited from AbstractMap, so to rectify that the respective methods are overridden and custom collections are provided that report the correct Spliterator characteristics.
The same sort of bug was reported and fixed in Caffeine, and the issue seems to exist in several other ConcurrentMap implementations in the wild.